@extends('layouts.app')

@section('content')
<style type="text/css">
	.tongjitu_tb tr {
		height: 45px;
	}
	
	.dizhi {
		width: 320px;
	}
	.dizhi select {
		width: 150px;
		display: inline-block;
	}
	.sousou {
		width: 100%;
		margin-top: 15px;
	}
	.paiming_color {
		width: 32px;
		height: 32px;
		display: inline-block;
		background: url("http://nb.yntosite.com/images/hui.png");
		vertical-align: middle;
		margin-right: 10px;
	}
	.paiming_color1 {
		background: url("http://nb.yntosite.com/images/jin.png");
	}
	.paiming_color2 {
		background: url("http://nb.yntosite.com/images/yin.png");
	}
	.paiming_color3 {
		background: url("http://nb.yntosite.com/images/tong.png");
	}
	.paiming_font {
		font-size: 14px;
		line-height: 45px;
		
	}
	.btn_color {
		    border-color: #adadad;
	        background-color: #ebebeb
	}
</style>
<div class="main-content">
    <div class="btn-toolbar list-toolbar">
    	
        <div class="form-all mg_t100">
        	<a href="javascript:history.back(-1);" class="easyui-linkbutton" data-options="iconCls:'icon-back'">返回</a>
        	<div class="clearfix sousou">
        		<div class="dizhi pull-left">
        			<select class="form-control" id="time_select">
	        			<option value="zhou" selected="selected">周</option>
	        			<option value="yue">月</option>
	        			<option value="nian">年</option>
	        		</select>
	        		<select class="form-control" id="city_select">
	        			<option value="shen">省</option>
	        			<option value="shi">市</option>
	        			<option value="qu">区</option>
	        			<option value="suo" selected="selected">派出所</option>
	        		</select>
        		</div>
        		<div class="chart_btns pull-right">
        			<button class="btn btn-default " id="zonghe">综合排行</button>
	             	<button class="btn btn-default btn_color" id="ryhc">人员核查数</button>
	             	<button class="btn btn-default " id="jqsb">警情上报数</button>
	             	<button class="btn btn-default " id="xsjb">举报线索数</button>
	             	<button class="btn btn-default " id="yjfk">意见反馈数</button>
         		</div>
        	</div>
        	
            
          <div id="div_print">
		    <table class="table-form table-border w mg-auto tongjitu_tb" style="margin-top: 30px;">
					<thead>
						<tr>
							<th colspan="11">企业排名统计表</th>
						</tr>
					</thead>
					<tbody>
						<tr class="thead">
							<td>企业排名</td>
							<td>企业名称</td>
							<td>数量</td>
						</tr>
						<!--<tr>
							<td>
								<span class="paiming_color paiming_color1"></span>
								<strong class="paiming_font">第1名</strong>
							</td>
							<td>荆州宾馆</td>
						</tr>-->
						
					</tbody>
				</table>

		</div>             

          </div>
    </div>
</div>
<script type="text/javascript">
	var btns ='ryhc';
	var city ='suo';
	var time ='zhou';
	var daTa ;
	$("#city_select").change(function(){
	     city = $(this).val();
	     time = $("#time_select").val();
	     console.log(city+","+time+","+btns);
	     paiming(city,time,btns)
	 });
	 $("#time_select").change(function(){
	     time = $(this).val();
	     city = $("#city_select").val();
	     console.log(city+","+time+","+btns);
	     paiming(city,time,btns)
	 });
	
	$("#zonghe").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 city = $("#city_select").val();
		 time = $("#time_select").val();
		 btns = $(this).attr("id");
		console.log(city+","+time+","+btns);
		paiming(city,time,btns)
	})
	
	$("#ryhc").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 city = $("#city_select").val();
		 time = $("#time_select").val();
		 btns = $(this).attr("id");
		console.log(city+","+time+","+btns);
		paiming(city,time,btns)
	})
	
	$("#jqsb").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 city = $("#city_select").val();
		 time = $("#time_select").val();
		 btns = $(this).attr("id");
		console.log(city+","+time+","+btns);
		paiming(city,time,btns)
	})
	
	$("#xsjb").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 city = $("#city_select").val();
		 time = $("#time_select").val();
		 btns = $(this).attr("id");
		console.log(city+","+time+","+btns);
		paiming(city,time,btns)
	})
	
	$("#yjfk").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 city = $("#city_select").val();
		 time = $("#time_select").val();
		 btns = $(this).attr("id");
		console.log(city+","+time+","+btns);
		paiming(city,time,btns)
	})
	
		paiming('suo','zhou','ryhc')
		function paiming(city,time,btns){
     	$.ajax({
    	 	type:"POST",
    	 	url:"{{url('admin/qyph/getnew')}}",
    	 	async:true,
    	 	data: {'city':city,'time':time,'btn':btns,'_token':'{{csrf_token()}}'},
    	    dateType: 'json',
    	    success : function(data){
    	    	var obj = {};
    	        var obj = jQuery.parseJSON(data);
    	        daTa = obj.message;
    	        console.log(obj);
    	        console.log(daTa);
    	        if(daTa.rank.length == 0){
    	        	 $(".tongjitu_tb .thead").nextAll().remove();
    	        	 var inner_data = '<tr>'+
										 '<td colspan="3">暂无数据</td>'+
									 '</tr>'
						      	  $(".tongjitu_tb tr").eq(-1).after(inner_data);		
    	        }else{
    	        	 $(".tongjitu_tb .thead").nextAll().remove();
    	        	 for(var i =0;i<daTa.rank.length;i++){
    	        	 	 	 console.log(daTa.rank[i].rank)
	        	 	 	 		var inner_data = '<tr>'+
												 '<td><span class="paiming_color paiming_color'+daTa.rank[i].rank+'"></span>'+
												 	  '<strong class="paiming_font">第'+daTa.rank[i].rank+'名</strong></td>'+
												
												 '<td>'+daTa.rank[i].name+'</td>'+
												 '<td>'+daTa.rank[i].count+'</td>'+
										 	'</tr>'
							 	 $(".tongjitu_tb tr").eq(-1).after(inner_data);			 
    	        	 	 		
    	        	 }
    	        }
    	         
    	        /*$(".tongjitu_tb").find("span").eq(0).addClass("paiming_color1");
			 	  $(".tongjitu_tb").find("span").eq(1).addClass("paiming_color2");
			 	  $(".tongjitu_tb").find("span").eq(2).addClass("paiming_color3");*/
    	    }
    	   
    	 });
 	  }
 	  
 	 
</script>

@stop
